//
//  CYRouter.h
//  TCRouteDemo
//
//  Created by candy on 2018/11/4.
//  Copyright © 2018年 lincy. All rights reserved.
//

#import <Foundation/Foundation.h>
#define CY_ROUTER_DEBUG 1
#if CY_ROUTER_DEBUG
#define CYRouterLog(fmt, ...) NSLog((@":\n[=>File]:%s\n[=>Warning]: " fmt), __FILE__, ##__VA_ARGS__)
#else
#define CYRouterLog(...);
#endif

typedef BOOL (^CYRouteMiddlewareBlk)(NSDictionary *params);
typedef void (^CYRouteHandlerBlk)(NSDictionary *params);

@interface CYRouteFormat : NSObject
@property (nonatomic, strong) NSString *path;
@property (nonatomic, copy) CYRouteHandlerBlk handler;
@end

@interface CYRouteResponse : NSObject
@property (nonatomic, strong) NSString *path;
@property (nonatomic, copy) CYRouteHandlerBlk handler;
@property (nonatomic, copy) NSDictionary *params;
@end

@interface CYRouter : NSObject

@property (nonatomic, strong) NSString *host;
@property (nonatomic, strong) NSArray<NSString *> *aliases;
@property (nonatomic, strong) NSMutableDictionary <NSString*,NSMutableDictionary*> *schemes;


+ (instancetype)share;

- (void)addRoute:(NSString *)route paramRegexs:(NSDictionary *)paramRegexs handler:(CYRouteHandlerBlk)handler;
- (void)addRoute:(NSString *)route paramRegexs:(NSDictionary *)paramRegexs middleware:(CYRouteMiddlewareBlk)middleware handler:(CYRouteHandlerBlk)handler;
- (CYRouteResponse *)prase:(NSString *)urlStr;

@property (nonatomic, copy) CYRouter *(^add)(NSString *route);
@property (nonatomic, copy) CYRouter *(^group)(NSString *route);


@end


